# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# Taken from: http://www.wagner-flo.net/svn/portage-overlay/app-admin/webdruid/

DESCRIPTION="Webserver log file analyzer"
HOMEPAGE="http://www.webdruid.org/"
SRC_URI="http://wagner-flo.net/svn/portage-overlay/app-admin/webdruid/distfiles/${P}.tar.bz2"

LICENSE="GPL-2"
KEYWORDS="x86 amd64"
RESTRICT="nomirror"
IUSE="dns graphviz"

DEPEND=">=media-libs/freetype-2.1.5
	>=sys-libs/zlib-1.2.1
	>=media-libs/libpng-1.2
	>=media-libs/gd-1.8.4
	dns? ( =sys-libs/db-1.85-r1 )"
RDEPEND="$DEPEND
    media-fonts/freeserif
	graphviz? ( >=media-gfx/graphviz-1.10 )"

src_unpack() {
	unpack ${A}
    cd ${WORKDIR}/${P}
}

src_compile() {
    if use dns; then
		myconf="--enable-dns --with-db=/usr/include/db1/ --with-dblib=/usr/lib/libdb1.so"
    else
        myconf=""
	fi

	CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
    
	econf ${myconf} || die
	make || die
}

src_install() {
  into /usr
  dobin webdruid
  dosym webdruid /usr/bin/webdruid-resolve
  doman webdruid.1
  dodoc CHANGELOG COPYING DNS.README README*

  insinto /etc/webdruid
  newins sample.conf webdruid.conf
  doins engines.list.local
  doins skins/classic/skin-classic.xml.conf

  insinto /usr/share/webdruid
  doins engines.list

  insinto /usr/share/webdruid/classic
  doins skins/classic/apply_skin.sh
  doins skins/classic/bullet.png
  doins skins/classic/bullet2.png
  doins skins/classic/left_arrow.png
  doins skins/classic/right_arrow.png
  doins skins/classic/separator.png
  doins skins/classic/classic.css
  doins skins/classic/classic.xsl
  doins skins/classic/shared.xsl
  
  
  for l in po/*.mo
  do
    insinto /usr/share/locale/$(basename ${l%.mo})/LC_MESSAGES
    newins $l webdruid.mo
  done
}
